package hello

import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.cloud.client.ServiceInstance
import org.springframework.cloud.client.discovery.DiscoveryClient
import org.springframework.cloud.client.discovery.EnableDiscoveryClient
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

/**
 * Created by hunter on 17-11-11.
 */
@EnableDiscoveryClient
@SpringBootApplication
class EurekaClientApplication {
    static main(args) {
        new SpringApplication(EurekaClientApplication.class).run(args)
    }
}


@RestController
class ServiceInstanceRestController {
    @Autowired
    private DiscoveryClient discoveryClient

    @RequestMapping("/service-instances/{applicationName}")
    List<ServiceInstance> serviceInstancesByApplicationName(@PathVariable String applicationName) {
        this.discoveryClient.getInstances(applicationName)
    }
}
